import { createRouter, createWebHistory } from 'vue-router'
const router = createRouter({
    history: createWebHistory(),
    routes: [
        {
            path: '/login', component: () => import('@/views/login.vue') //登录页
        },
        {
            path: '/',
            component: () => import('@/views/Layout.vue'),
            //重定向子路径
            redirect: '/sy',
            children: [
                {
                    path: '/sy',
                    component: () => import('@/views/sy.vue'),
                    meta: {
                        title: '首页'
                    }
                },
                {
                    path: '/manage/swiper',
                    component: () => import('@/views/管理/Swiper.vue'),
                    meta: {
                        title: '轮播图管理'
                    }
                },
                {
                    path: '/self',
                    component: () => import('@/views/self.vue'),
                    meta: {
                        title: '个人中心'
                    }
                },
                {
                    path: '/manage/people',
                    component: () => import('@/views/管理/people.vue'),
                    meta: {
                        title: '人员管理'
                    }
                },
                {
                    path: '/manage/stu',
                    component: () => import('@/views/管理/xs.vue'),
                    meta: {
                        title: '学生管理'
                    }
                },
                {
                    path: '/manage/tiku',
                    component: () => import('@/views/管理/tiku.vue'),
                    meta: {
                        title: '题库管理'
                    }
                },
                {
                    path: '/manage/classroom',
                    component: () => import('@/views/管理/classroom.vue'),
                    meta: {
                        title: ''
                    }
                },
                {
                    path: '/manage/student',
                    component: () => import('@/views/管理/student.vue'),
                    meta: {
                        title: ''
                    }
                },
                {
                    path: '/manage/class',
                    component: () => import('@/views/管理/class.vue'),
                    meta: {
                        title: ''
                    }
                },
                {
                    path: '/manage/homework',
                    component: () => import('@/views/管理/homework.vue'),
                    meta: {
                        title: ''
                    }
                },
                {
                    path: '/text',
                    component: () => import('@/views/管理/text.vue'),
                    meta: {
                        title: ''
                    }
                },
                {
                    path: '/audio',
                    component: () => import('@/views/管理/audio.vue'),
                    meta: {
                        title: ''
                    }
                },
            ]
        }
    ]
})

// router.beforeEach(async (to, from, next) => {
//     // if (to.path === '/login') {
//     //   next()
//     // } else {
//     //   //发送请求
//     //   const { data: { res } } = await http.get('getResources');
//     //   //获取返回的动态数据，生成路由配置
//     //   const dynmicRoutes = addDynmicRoutes(res);
//     //
//     // }
//     next()
// })
export default router